//
//  GKZYPostBarImageShowView.m
//  GKZYAid
//
//  Created by lanou3g on 16/3/14.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYPostBarImageShowView.h"

@implementation GKZYPostBarImageShowView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self addAllViews];
    }
    return self;
}

- (void)addAllViews
{
    self.backgroundColor = [UIColor whiteColor];
    self.scrollViewImage = [[UIScrollView alloc] initWithFrame:self.frame];
    self.scrollViewImage.backgroundColor = [UIColor whiteColor];
    self.scrollViewImage.pagingEnabled = YES;
    self.scrollViewImage.showsHorizontalScrollIndicator = NO;
    [self addSubview:self.scrollViewImage];
}

- (void)setArrayAllImages:(NSMutableArray *)arrayAllImages
{
    self.scrollViewImage.contentSize = CGSizeMake(self.frame.size.width * (arrayAllImages.count - 1), 0);
    for (int i = 0; i < arrayAllImages.count - 1; i++) {
        UIScrollView *subScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(self.frame.size.width * i, 0, self.frame.size.width, self.frame.size.height)];
        subScrollView.contentSize = CGSizeMake(self.frame.size.width, 0);
        subScrollView.tag = 101 + i;
        subScrollView.minimumZoomScale = 0.5;
        subScrollView.maximumZoomScale = 3.0;
        UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        AVFile *fileImage = arrayAllImages[i];
        [imageV sd_setImageWithURL:[NSURL URLWithString:fileImage.url] placeholderImage:nil];
        [subScrollView addSubview:imageV];
        [self.scrollViewImage addSubview:subScrollView];
    }
}

- (void)setIndex:(NSInteger)index
{
    self.scrollViewImage.contentOffset = CGPointMake(index * [UIScreen mainScreen].bounds.size.width, 0);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
